<template>
    <div>
      <Card class="clearfix" style="padding-bottom: 16px">
        <p slot="title">
          金融管理
        </p>
        <Form label-position="left" :label-width="72">
          <Row :gutter="15">
            <i-col span="6">
              <FormItem label="联系方式：">
                <Input v-model="mobile" placeholder="请输入手机号码"/>
              </FormItem>
            </i-col>
            <i-col span="6">
              <Button type="success" @click="searchData" icon="ios-search" >搜索</Button>
            </i-col>
          </Row>
        </Form>
        <div>
            <list-table refs="table1" v-model="tableData" :access="access" :table-data="tableData"></list-table>
        </div>
        <Page ref="pages" :total="itemTotal" show-total style="float: right; margin-top: 20px" @on-change="getList"></Page>
      </Card>
    </div>
</template>

<script>
import listTable from './components/listTable.vue'
import ajax from '../../../libs/axios.js'
export default {
    name: 'financeindex',
    components: {
        listTable
    },
    data () {
        return {
            loginName: '',            // 用户名称
            mobile:'',                // 手机号
            name:'',                  // 搜索名称
            itemTotal: 0,             // 目前在没有找到合适的获取数据总个数之前，先使用默认值数据
            tableData: [],
            access:{
                edit: true,           // 控制编辑按钮显示
                func: true,
                remove: true
            }
        }
    },
    mounted () {
      this.init()
    },
    methods: {
        // 初始化数据
        init () {
           this.$store.commit('setActiveName', 'buycarindex');
           this.getList(1)
        },
        // 搜索
        searchData () {
            this.getList(1)
        },
        // 获取列表
        getList (page) {
            let _that = this;
            let url = 'adminlogin/car/selectBuyCars'
            let data = {
                mobile: this.mobile,
                pageSize: 10,
                pageNum: page
            }
            ajax.formRes(url, data).then(res => {
                _that.tableData = res.data;
                _that.itemTotal = res.count;
            }).catch(res => {
                console.log('有错误信息')
            })
        }
    }
}
</script>

<style lang="less">
  @import "../../../styles/common.less";
  @import "../../../styles/table.less";
</style>

